# install package if necessary
# install.packages("xtable")

library(xtable)

load("dataan/data/twin_placebo.rdata")

# create empty table 
plac1_tab <- 
  matrix(NA, nrow = 5, ncol = 2)

# Assign column names
colnames(plac1_tab) <-
  c("Mothers", "Fathers")

# Assign row names
rownames(plac1_tab) <- 
  c("Twinning in first parity",
    "2",
    "Turnout if one child in first parity",
    "N",
    "Share with twins")

# Assign values to table
for(i in 1:2){
  # Assign reduced form estimate
  plac1_tab[1, i] <- round(outtab_placebo[[i]][3,1], 3)
  # Assign standard error
  plac1_tab[2, i] <- paste("(",round(outtab_placebo[[i]][3,2], 3),")", sep ="")
  # Assign turnout rate for parents with one child in first parity
  plac1_tab[3, i] <- round(outtab_placebo[[i]][1,1], 3)
  # Assign N
  plac1_tab[4, i] <- sum(outtab_placebo[[3]][i,])
  # Assign share with twins
  plac1_tab[5, i] <- round(outtab_placebo[[3]][i,2]/sum(outtab_placebo[[3]][i,]), 3)
}

# Print table
xtable(plac1_tab)
